//
//  APIManager.h
//  minidai
//
//  Created by 容贤郁 on 2017/5/21.
//  Copyright © 2017年 迷你金服. All rights reserved.
//

#import <XMNetworking/XMNetworking.h>

typedef NS_ENUM(NSInteger, Response) {
    ResponseFailure = -1,
    ResponseSuccess = 1
};

@class ResponseModel;

@interface APIManager : XMCenter

+ (NSString *)sendRequestWithPath:(NSString *)path parameters:(NSDictionary *)params method:(XMHTTPMethodType)method onSuccess:(void(^)(ResponseModel *responseModel))success onFailure:(void (^)(NSError *error))failure;

+ (NSString *)sendRequestWithURL:(NSString *)url parameters:(NSDictionary *)params method:(XMHTTPMethodType)method onSuccess:(void (^)(ResponseModel *responseModel))success onFailure:(void (^)(NSError *error))failure;



/**
 下载文件

 @param url 文件地址
 @param progressBlock 进度
 @param success 下载成功
 @param failure 下载失败
 @param finish 下载完成
 @return 网络请求标识
 */
+ (NSString *)downloadWithUrl:(NSString *)url
                   onProgress:(void (^)(NSProgress *))progressBlock
                    onSuccess:(void (^)(ResponseModel *))success
                    onFailure:(void (^)(NSError *))failure
                     onFinish:(void (^)(id, NSError *))finish;



/**
 单张或者多张图片上传
 
 @param url 上传图片地址
 @param params 参数
 @param images 图片
 @param names 图片对应的名称
 @param progressBlock 上传进度
 @param success 上传成功
 @param failure 上传失败
 @param finish 上传完成
 @return 请求的标识identifier
 */
+ (NSString *)uploadWithUrl:(NSString *)url
                 parameters:(NSDictionary *)params
               uploadImages:(UIImage *)image
                  imageName:(NSString *)imageName
                 onProgress:(void (^)(NSProgress *))progressBlock
                  onSuccess:(void (^)(id))success
                  onFailure:(void (^)(NSError *))failure
                   onFinish:(void (^)(id, NSError *))finish;


+ (void)addGeneralHeaders;

//+ (NSString *)sendBatchRequest:(XMBatchRequestConfigBlock)configBlock onSuccess:(XMBCSuccessBlock)successBlock onFailure:(XMBCFailureBlock)failureBlock onFinished:(XMBCFinishedBlock)finishedBlock

@end




@interface ResponseModel : NSObject

@property (nonatomic, strong) id data;
@property (nonatomic, strong) id msg;
@property (nonatomic, strong) NSError *error;
@property (nonatomic) Response status;

@end
